package observer;

import java.util.Vector;

public class Server implements Subject {

    private String updateMessage;

    private Vector<Observer> vecObserver;

    public Server() {
        this.vecObserver = new Vector<>();
    }

    @Override
    public void attach(Observer observer) {
        vecObserver.add(observer);
    }

    @Override
    public void detach(Observer observer) {
        vecObserver.remove(observer);
    }

    @Override
    public void notifyToAll() {
        for (int i = 0; i < vecObserver.size(); i++) {
            vecObserver.get(i).update(this);
        }
    }

    @Override
    public void setMessage(String string) {
        this.updateMessage = string;
    }

    @Override
    public String getMessage() {
        return updateMessage;
    }


}
